
import Phaser from "phaser";

const _rectangle = Symbol('_rectangle');
const _line = Symbol('_line');
export class Graphical extends Phaser.GameObjects.Graphics {
    constructor(_options, _that) {
        super(_that);
        _options.path ? this[_line](_options) : this[_rectangle](_options);
    }

    [_rectangle](_options) {
        this.fillStyle(_options.style.col, _options.style.alp);
        this.fillRect(_options.rec.x, _options.rec.y, _options.rec.w, _options.rec.h);
        this.setVisible(_options.vis);
        this.generateTexture(_options.gen.genKey, _options.gen.w, _options.gen.h);
        _options.des ? this.destroy() : null;
    }

    [_line](_options) {
        this.lineStyle(1, 0x00FF00, 1);
        this.fillStyle(0x00FF00, 1);
        _options.des ? this.destroy() : null;
    }
}

export class Line extends Phaser.Curves.Spline {
    constructor(_data, _PathKey) {
        super(_data);
        this.draw(_PathKey, 128);
    }
}